package Iterator;

import java.util.*;
import java.util.function.Consumer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:38917
 * Date:2025/4/16
 * Time:17:05
 */
public class Test {
    //测试iterator
    /*public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");
        list.add("d");
        list.add("e");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String cur = iterator.next();
            System.out.println(cur);
            if(cur.equals("a")){
                iterator.remove();
            }
        }
        System.out.println("============================");
    }*/
    /*public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        Iterator<Integer> iterator = list.iterator();
        //重写Consumer对象中的accept方法,该方法内部可以对遍历的元素进行执行的操作
        //lambda表达式
       iterator.forEachRemaining(integer -> {
           integer += 1;
           System.out.println(integer);
       });
        System.out.println("===============================================");
    }*/



    //测试forEach&foreach
    /*public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        for (Integer i : list) {
            System.out.println(i);
        }
        list.forEach(new Consumer<>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }
        });
    }*/



    //
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        Spliterator<Integer> spliterator = list.spliterator();

    }
}
